翻訳と辞書
Words near each other
・ Class Guitar
・ Class hierarchy
・ Class I
・ Class I PI 3-kinases
・ Class I recall
・ Class II
・ Class II bacteriocin
・ Class II gene
・ Class II PI 3-kinases
・ Class III
・ Class III PI 3-kinase
・ Class III β-tubulin
・ Class implementation file
・ Class in Aztec society
・ Class in Marxist theory
Class invariant
・ Class kappa function
・ Class kappa-ell function
・ Class Library for Numbers
・ Class logic
・ Class M
・ Class M planet
・ Class Mythology
・ Class number
・ Class number formula
・ Class number problem
・ Class of '44
・ Class of '55
・ Class of '61
・ Class of '76


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Class invariant : ウィキペディア英語版
Class invariant

In computer programming, specifically object-oriented programming, a class invariant (or type invariant) is an invariant used to constrain objects of a class. Methods of the class should preserve the invariant. The class invariant constrains the state stored in the object.
Class invariants are established during construction and constantly maintained between calls to public methods. Temporary breaking of class invariance between private method calls is possible, although not encouraged.
An object invariant, or representation invariant, is a computer programming construct consisting of a set of invariant properties that remain uncompromised regardless of the state of the object. This ensures that the object will always meet predefined conditions, and that methods may, therefore, always reference the object without the risk of making inaccurate presumptions. Defining class invariants can help programmers and testers to catch more bugs during software testing.
==Class invariants and inheritance==

The useful effect of class invariants in object-oriented software is enhanced in the presence of inheritance. Class invariants are inherited, that is, "the invariants of all the parents of a class apply to the class itself."〔Meyer, Bertrand. ''Object-Oriented Software Construction, second edition,'' Prentice Hall, 1997, p. 570.〕
Inheritance can allow descendant classes to alter implementation data of parent classes, so it would be possible for a descendant class to change the state of instances in a way that made them invalid from the viewpoint of the parent class. The concern for this type of misbehaving descendant is one reason object-oriented software designers give for favoring composition over inheritance (i.e., inheritance breaks encapsulation).〔E. Gamma, R. Helm, R. Johnson, and J. Vlissides. ''Design Patterns: Elements of Reusable Object-Oriented Software.'' Addison-Wesley, Reading, Massachusetts, 1995., p. 20.〕
However, because class invariants are inherited, the class invariant for any particular class consists of any invariant assertions coded immediately on that class, logically "and-ed" with all the invariant clauses inherited from the class's parents. This means that even though descendant classes may have access to the implementation data of the their parents, the class invariant can prevent them from manipulating those data in any way that produces an invalid instance at runtime.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Class invariant」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.